import React from 'react'
import { Table} from 'antd';
import axios from '../../utils/http'
import {QUERYARTICLECLASS} from '../../utils/api'


class ArticleClassificationTable extends React.Component{
      constructor(){
          super()
          this.state={
                //   表格的头部
                columns:[
                    {
                      title: '分类ID',
                      dataIndex: 'articleCid',
                    },
                    {
                      title: '系统名称',
                      dataIndex: 'systemName',
                    },
                    {
                      title: '分类名称',
                      dataIndex: 'articleCname',
                    }, 
                    {
                        title: '分类介绍',
                        dataIndex: 'articleCc',
                      },
                      {
                        title: '操作',
                        key: 'operation',
                        fixed: 'right',
                        width: 100,
                        render: (x,y,z) =><div style={{color:'#4E6EF2'}}><span onClick={this.modification.bind(this,y)}>修改</span></div>,
                      },
                ],
    
                //  表格数据
                data:[],
                // 表格的分页
                pagination:{  pageSize: 4,},    
    
                  
             }
      }  
// 生命周期
componentWillMount() {
  //  查询所有广告
  axios({
    method:'get',
    url:QUERYARTICLECLASS
  }).then((data) => {
    for (let i = 0; i < data.data.data.length; i++) {
            data.data.data[i].key=i   
    }
    this.setState({
      data: [...data.data.data]
    })
  })
}




// 修改
modification=(y)=>{
    this.props.history.push({pathname:"/Home/wangZhan/ArticleClassification/ModifyArticleClassification",query: { name : y }});
}


    render(){
        return(
            <div>
            <Table pagination={this.state.pagination} columns={this.state.columns} dataSource={this.state.data} />
            </div>
        )
    }

}

export default ArticleClassificationTable